def is_prime(num):
    if num < 2:
        return False
    for i in range(2, int(num ** 0.5) + 1):
        if num % i == 0:
            return False
    return True


def closest(a):
    b = a.split()

    if len(b) != 3:
        print("Wrong input")
        return

    s = ""
    for word in b:
        if word == "zero":
            s += "0"
        elif word == "one":
            s += "1"
        elif word == "two":
            s += "2"
        elif word == "three":
            s += "3"
        elif word == "four":
            s += "4"
        elif word == "five":
            s += "5"
        elif word == "six":
            s += "6"
        elif word == "seven":
            s += "7"
        elif word == "eight":
            s += "8"
        elif word == "nine":
            s += "9"

    if not s.isdigit() or len(s) != 3:
        print("Wrong input")
        return

    number = int(s)

    l = number
    r = number
    while True:
        if is_prime(l):
            print(l)
            return
        if is_prime(r):
            print(r)
            return
        l -= 1
        r += 1


text = input()
closest(text)